package com.klangner.lucene.index
{
  import flash.utils.IDataInput;
  
  /**
  * Segment data
  */
	public class Segments{
		
		/** generation of segment file */
		private var _format:int;
		private var _version:int;
		private var _size:int;
		
		/**
		 * Open last generation Segment from given index directory
		 */
		public function Segments(input:IDataInput){
		  loadData(input);
		}
		
		/**
		 * Get segment format
		 */
		public function getFormat(): int{
		  return _format;
		}
		
		/**
		 * Get segment
		 */
		public function getSegment(index:int): Segment{
		  return null;
		}
		
		/**
		 * Get number of segments
		 */
		public function getSize(): int{
		  return _size;
		}
		
		/**
		 * Get segment version
		 */
		public function getVersion(): int{
		  return _version;
		}

    // ------------------------------------------------------------------------		
		/**
		 * Load segment data from file
		 */
		private function loadData(input:IDataInput):void{
		  var reader:InputReader = new InputReader(input);
		  var segCount:int;
		  
		  _format = reader.getInt32();
		  _version = reader.getInt64();
		  // skip name counter
		  reader.getInt32();
		  segCount = reader.getInt32();
		  
		  _size = segCount;
		}

	}
}